#include <REGX52.H>
#include "timer0.h"
#include "Key.h"
#include <INTRINS.H>

//unsigned char KeyNum;

// void main()
// {
//	 //Timer0Init();
//	 while(1)
//	 {
//		 KeyNum = Key();
//		 if(KeyNum)
//		 {
//			 if(KeyNum==1)P2_1 = ~P2_1;
//			 if(KeyNum==2)P2_2 = ~P2_2;
//			 if(KeyNum==3)P2_3 = ~P2_3;
//			 if(KeyNum==4)P2_4 = ~P2_4;
//		 }
//	 }
// }

 unsigned char KeyNum;
 unsigned int  LEDMode=0;

 void main()
 {
	 P2=0xFE;
	 Timer0Init();
	 while(1)
	 {
		 KeyNum = Key();
		 if(KeyNum)
		 {
			 if(KeyNum==1)
			 {
				 	LEDMode++;
				 	if(LEDMode>=2)LEDMode=0;
			 }
		 }
	 }
 }
 
 void Timer0_Routine() interrupt 1
{
	static unsigned int T0Count;
	TL0 = 0X66;
	TH0 = 0XFC;
	T0Count++;
	if(T0Count>=500)
	{
		T0Count = 0;
		if(LEDMode==0)
			P2=_crol_(P2,1);
		if(LEDMode==1)
			P2=_cror_(P2,1);
	}
}

